<?php

  class Configurator extends Base implements IConfigurator {

    /** The array used to store all configuration variables and values. */
    private $Items = array();

    /**
     * Store all configuration options.
     * @link http://be.php.net/manual/en/function.ini-get-all.php
     */
    public function __construct() {
      $this->Items = ini_get_all();
    }

    /**
     * Gets indirectly the value of a key in a specified section.
     * @param String $section The section to browse for the specified key.
     * @param const $key The key to search in the specified section.
     * @return String The value of the key.
     */
    public function getValue(IString $section, $key = self::LOCALE) {
      return new String(strval($this->Items[$section->toString()][$key]));
    }

    /**
     * Sets directly the value of a configuration option.
     * The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.
     * @param String $variable Not all the available options can be changed using setValue().
     * There is a list of all available options in the appendix.
     * @param String $value The new value for the option.
     * @link http://be.php.net/manual/en/ini.list.php
     * @link http://be.php.net/manual/en/function.ini-set.php
     */
    public static function setValue(IString $variable, IString $value) {
      $return = ini_set($variable->toString(), $value->toString());
      return $return === false ? new Boolean(false) : new String($return);
    }

    /**
     * Gets directly the value of a configuration option.
     * Returns the value of the configuration option on success.
     * @param String $variable The configuration option name.
     * @return String The value of the configuration option on success, or an empty string on failure or for null values.
     * @link http://be.php.net/manual/en/function.ini-get.php
     */
    public static function get(IString $variable) {
      return new String(ini_get($variable->toString()));
    }

    /**
     * Outputs lots of PHP information.
     * @param const $what The output may be customized by passing one or more of the following constants bitwise values summed together in the optional $what parameter.
     * One can also combine the respective constants or bitwise values together with the or operator.
     * @return Boolean True on success or false on failure.
     * @link http://fr2.php.net/manual/en/function.phpinfo.php
     */
    public static function info($what = null) {
      return $what == null ? new Boolean(phpinfo()) : new Boolean(phpinfo($what));
    }

    /**
     * Restores the value of a configuration option.
     * Restores a given configuration option to its original value.
     * @param String $value The configuration option name.
     * @link http://be.php.net/manual/en/function.ini-restore.php">ini_restore()</a>
     */
    public static function restore(IString $variable) {
      ini_restore($variable->toString());
    }

  }

?>
